package com.north.light.androidutils.recyclerview.scrollview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.north.light.androidutils.log.LogUtil;

/**
 * FileName: PagerSnapRecyclerView
 * Author: lzt
 * Date: 2022/9/14 11:31
 */
public class PagerSnapRecyclerView extends ScrollStringRecyclerView {

    private int startX;
    private int startY;

    public PagerSnapRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // 让父类不要拦截该view的事件
        LogUtil.d("PagerSnapRecyclerView onInterceptTouchEvent");
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        LogUtil.d("PagerSnapRecyclerView onTouchEvent");
        return super.onTouchEvent(ev);
    }

//    @Override
//    public boolean dispatchTouchEvent(MotionEvent ev) {
//        switch (ev.getAction()) {
//            case MotionEvent.ACTION_DOWN:
//                startX = (int) ev.getX();
//                startY = (int) ev.getY();
//                getParent().requestDisallowInterceptTouchEvent(true);
//                break;
//            case MotionEvent.ACTION_MOVE:
//                int endX = (int) ev.getX();
//                int endY = (int) ev.getY();
//                int disX = Math.abs(endX - startX);
//                int disY = Math.abs(endY - startY);
//                // 水平方向滑动
////                if (disX > disY) {
////                    // 左滑
////                    if ((endX - startX) > 0 && getCurrentPage() == 0) {
////                        getParent().requestDisallowInterceptTouchEvent(false);
////                    } else {
////                        getParent().requestDisallowInterceptTouchEvent(true);
////                    }
////                } else {
////                    getParent().requestDisallowInterceptTouchEvent(false);
////                }
//                LogUtil.d("endX: " + endX + "endY: " + endY + "disX: " + disX + "disY: " + disY);
//                getParent().requestDisallowInterceptTouchEvent(true);
//                break;
//            case MotionEvent.ACTION_UP:
//            case MotionEvent.ACTION_CANCEL:
//                getParent().requestDisallowInterceptTouchEvent(false);
//                break;
//        }
//        return super.dispatchTouchEvent(ev);
//    }


}
